<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
test(function(t) {

var ctx = document.createElement('canvas').getContext('2d');
    assert_equals(ctx.imageSmoothingEnabled, true);
    
    ctx.imageSmoothingEnabled = false;
    assert_equals(ctx.imageSmoothingEnabled, false);
    
    ctx.save();
    ctx.imageSmoothingEnabled = true;
    ctx.restore();
    assert_equals(ctx.imageSmoothingEnabled, false);
    
    var image = document.createElement('canvas');
    image.width = 2;
    image.height = 1;
    
    // We use this to color the individual pixels
    var dotter = ctx.createImageData(1, 1);
    
    // Color the left pixel black.
    dotter.data.fill(0);
    dotter.data[3] = 255;
    image.getContext('2d').putImageData(dotter, 0, 0);
    
    // Color the right pixel white.
    dotter.data.fill(255);
    image.getContext('2d').putImageData(dotter, 1, 0);
    
    var canvas = document.createElement('canvas');
    canvas.width = 4;
    canvas.height = 1;
    ctx = canvas.getContext('2d');
    ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
    left_of_center_pixel = ctx.getImageData(1, 0, 1, 1);
    
    assert_not_equals(left_of_center_pixel.data[0], 0);
    assert_not_equals(left_of_center_pixel.data[1], 0);
    assert_not_equals(left_of_center_pixel.data[2], 0);
    
    ctx.imageSmoothingEnabled = false;
    ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
    left_of_center_pixel = ctx.getImageData(1, 0, 1, 1);
    
    assert_equals(left_of_center_pixel.data[0], 0);
    assert_equals(left_of_center_pixel.data[1], 0);
    assert_equals(left_of_center_pixel.data[2], 0);
    
    ctx.imageSmoothingEnabled = true;
    ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
    left_of_center_pixel = ctx.getImageData(1, 0, 1, 1);
    
    assert_not_equals(left_of_center_pixel.data[0], 0);
    assert_not_equals(left_of_center_pixel.data[1], 0);
    assert_not_equals(left_of_center_pixel.data[2], 0);
    
    ctx.imageSmoothingEnabled = false;
    ctx.save();
    ctx.imageSmoothingEnabled = true;
    ctx.restore();
    ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
    left_of_center_pixel = ctx.getImageData(1, 0, 1, 1);
    assert_equals(left_of_center_pixel.data[0], 0);
    assert_equals(left_of_center_pixel.data[1], 0);
    assert_equals(left_of_center_pixel.data[2], 0);
    
    }, "Tests for the imageSmoothingEnabled attribute.");
</script>
</body>
